<?php
/**
 * Author：晴天 QQ：1186258278
 * Creation：2020/4/27 15:46
 * Filename：admin.docking.log.php
 * 对接日志
 */
$title = '货源对接日志';
include "header.php";
$Flie = ROOT . '/includes/extend/log/Supply/Supply_' . $accredit['token'] . '.log';
if (file_exists($Flie)) {
    $DataR = explode('SEGMENTATION', file_get_contents($Flie));
    $Data = [];
    foreach (array_reverse($DataR) as $value) {
        if ($value == '') continue;
        $Data[] = json_decode($value, TRUE);
    }
} else {
    $Data = [];
}
function unicodeDecode($unicode_str)
{
    if ($unicode_str == false) return '什么也没有,对接失败！';
    $a = json_decode($unicode_str, TRUE);
    if ($a == null) {
        $b = xiaochu_de($unicode_str);
        return (!is_null(json_decode($b)) ? unicodeDecode($b) : $unicode_str);
    } else {
        return json_encode($a, JSON_UNESCAPED_UNICODE);
    }
}

?>
<link href="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/css/vendor/dataTables.bootstrap4.css" rel="stylesheet"
      type="text/css"/>
<link href="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/css/vendor/responsive.bootstrap4.css" rel="stylesheet"
      type="text/css"/>
<!-- third party css end -->
<!-- App css -->

<link href="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/css/app.min.css" rel="stylesheet" type="text/css"/>
<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-header">
                货源对接日志
            </div>
            <div class="card-body">
                <table id="datatable-buttons" class="table table-striped dt-responsive nowrap"
                       style="white-space: nowrap">
                    <thead>
                    <tr>
                        <th>对接时间</th>
                        <th>URL</th>
                        <th>Post</th>
                        <th>返回内容</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php $i = 1;
                    foreach ($Data as $k => $v) {
                        $A = [];
                        foreach ($v as $key => $value) { ?>
                            <tr>
                                <td><?= $key ?></td>
                                <td><a href="javascript:msg('c_<?= $i ?>')">[查看]</a> <span
                                            id="c_<?= $i ?>"><?= $value['url'] ?></span></td>
                                <td><a href="javascript:msg('d_<?= $i ?>')">[查看]</a> <span
                                            id="d_<?= $i ?>"><?= json_encode($value['post'], JSON_UNESCAPED_UNICODE) ?></span>
                                </td>
                                <td style="height: auto"><a href="javascript:msg('s_<?= $i ?>')">[查看]</a> <span
                                            id="s_<?= $i ?>"><?= htmlspecialchars(unicodeDecode($value['data'])) ?></span>
                                </td>
                            </tr>
                            <?php
                        }
                        ++$i;
                    } ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<script src="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/js/app.min.js"></script>
<!-- third party js -->
<script src="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/js/vendor/jquery.dataTables.min.js"></script>
<script src="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/js/vendor/dataTables.bootstrap4.js"></script>
<script src="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/js/vendor/dataTables.responsive.min.js"></script>

<script src="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/js/vendor/dataTables.buttons.min.js"></script>
<script src="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/js/vendor/buttons.bootstrap4.min.js"></script>
<script src="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/js/vendor/buttons.html5.min.js"></script>

<script src="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/js/vendor/buttons.print.min.js"></script>
<!-- third party js ends -->
<!-- demo app -->
<script src="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/layui/layui.all.js"></script>
<script src="<?= $cdnserver == null ? '../' : $cdnserver ?>assets/js/pages/demo.datatable-init.js"></script>
<script>
    function msg(id) {
        layer.open({
            title: '查看内容',
            content: $("#" + id).html(),
            btn: false,
            shade: [0.8, '#393D49'],
            shadeClose: true,
        })
    }
</script>